package com.mxpio.erp.common.inventory.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @Author : 吴盼盼
 * @Datetime : 2022/10/6 15:49
 * @Desc : 盘点单主单
 * @Modor :  Modifytime:
 * @modDesc :
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INV_INVENTORY")
@Schema(description="盘点单主单")
public class Inventory extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Id
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Column(name = "INVENTORY_CODE_", updatable = false)
    @Schema(description = "盘点单号")
    private String inventoryCode;

    @Column(name = "INVENTORY_TYPE_")
    @Schema(description = "单据类型")
    @Dict(dicCode="ERP_INV_INVENTORY_TYPE")//初盘、复盘
    private String inventoryType;

    @Column(name = "INVENTORY_STATUS_")
    @Schema(description = "单据状态")
    @Dict(dicCode="ERP_INV_INVENTORY_STATUS")
    private String inventoryStatus;


    @Column(name = "INVENTORY_WAY_")
    @Schema(description = "盘点方法")
    @Dict(dicCode="ERP_INV_INVENTORY_WAY")
    private String inventoryWay;

    @Column(name = "INVENTORY_RANGE_")
    @Schema(description = "盘点范围")
    @Dict(dicCode="ERP_INV_INVENTORY_RANGE")
    private String inventoryRange;

    @Column(name = "INVENTORY_PERCENTAGE_")
    @Schema(description = "盘点比例(%)")
    private Integer inventoryPercentage;


    @Column(name = "INVENTORY_RANGE_BASIS_")
    @Schema(description = "比例依据")
    @Dict(dicCode="ERP_INV_INVENTORY_RANGE_BASIS")
    private String inventoryRangeBasis;

    @Column(name = "WH_CODE_")
    @Schema(description = "盘点仓库")
    @Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
    private String whCode;

    @Column(name = "BUSI_DATE_")
    @Schema(description = "账务日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date busiDate;

    @Column(name = "INVENTORY_PLAN_DATE_")
    @Schema(description = "计划盘点日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date inventoryPlanDate;

    @Column(name = "INVENTORY_ACTUAL_DATE_")
    @Schema(description = "实际盘点日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date inventoryActualDate;


    @Column(name = "INVENTORY_PERSONS_")
    @Schema(description = "盘点人员")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String inventoryPersons;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Transient
    private List<InventoryItem> itemList;

    @Transient
    private List<InventoryReview> reviewList;

    @Column(name = "CRITERIA_",length = 5000)
    @Schema(description = "盘点维度")
    private String criteria;

    @Column(name = "PLAN_CODE_")
    @Schema(description = "盘点计划编码")
    private String planCode;

    @Column(name = "IS_APPEND_")
    @Schema(description = "盘点中允许增加物料")
    @Dict(dicCode = "ERP_COMMON_YESNO")
    private Integer isAppend;


}
